import {
  getList
} from '../services/api';
import {
  getData
} from '../data/home/home';

export default {
  namespace: 'home',
  state: {
    data: null,
  },

  effects: {
    * getList({payload}, {call, put}) {
      const result = yield call(getList, {...payload});
      yield put({
        type: 'save',
        payload: result
      })
    }
  },

  reducers: {
    save(state, {payload}) {
      return {
        ...state,
        data: getData(payload)
      };
    },
  }

}
